<div class="profile-dn row">
	<div class="profile-wall medium-10 medium-centered large-10 large-centered column">
		<div class="profile-left-wall medium-7 large-7 columns">

			  <div id="contentstage" class="large-12 column" style="padding:0;">

<div id="postContainer">
<?php foreach ($feeds as $value) { ?>
	<!--wall post starts here-->

 <div id="<?= $value->uft->id ?>" class="wall-post large-12 columns">
	<div class="wall-head large-12 column">
		<div class="dp-tmb medium-1 large-1 columns" style="background:url('<?= IMAGE_URL_SMALL.$value->uat->profile_pic ?>');background-size:cover;">
		</div>
		<div class="wall-info medium-9 large-9 columns">
			<a href="<?= BASE_URI.'profile?bhd='.$value->uat->id; ?>"><?= $value->uat->fname.' '.$value->uat->lname ?></a>
			<p><small><i class="fa fa-clock-o"> <abbr class="timeago" title="<?= $value->uft->date_created ?>"></abbr></i></small></p>
		</div>
		<div class="extra medium-1 large-1 column"></div>
	</div>
	<div class="wall-content large-12 column">
		<p><?= $value->uft->feed_title ?></p>
		<?= $value->uft->feed_container ?>
	</div>
	<div class="wall-att large-12 column">
	</div>
	<div class="likeshare large-12 column">
		<div class="medium-6 large-6 column">
			<ul class="inline-list">
				<li><a id="feed_like_id_<?= $value->uft->id ?>" feed-like-id="<?= $value->uft->id ?>"class="btnLike"><?php if(FeedsLikesTb::checkIfLiked($value->uft->id,$this->session->get('user_id')) == true){
					echo "Unlike";
				}else{
					echo "Like";
				}
				?></a></li>
				<li><a>Comment</a></li>
				<li><a>Report</a></li>
			</ul>
		</div>
		<div class="text-right medium-4 large-4 column">
			<p id="feeds_total_likes_<?= $value->uft->id ?>"><?= FeedsLikesTb::countLikes($value->uft->id) ?> People like this</p> 
		</div>
	</div>
	<div class="commentsection large-12 column">
		<div class="textareafrm">
			<textarea class="commentbox textarea-xpnd" id="<?= $value->uft->id ?>" receiver-id="<?= $value->uat->id ?>" placeholder="Comment"></textarea>
		</div>
		<div id="<?= 'feeds_comment_'.$value->uft->id ?>" class="commentarea large-12 column">
			<?php foreach (FeedsCommentsTb::find(array(
					"conditions"=>"feeds_id = ?0",
					"bind"=>array(0=>$value->uft->id)
				)) as $comment) { ?>
			<div id="<?= $comment->id ?>" class="usercomment large-12 column">
				<div class="dp-comment medium-1 large-1 columns" style="background:url('<?= IMAGE_URL_SMALL.UserAccountTb::getProfilePicUrl($comment->user_id) ?>');background-size:cover;">
				</div>
				<div class="usercommentinfo medium-9 large-10 column">
						<a href="<?=  BASE_URI.'profile?bhd='.$comment->user_id; ?>"><?= UserAccountTb::getFullname($comment->user_id); ?></a>&nbsp;&nbsp;<small><i class="fa fa-clock-o"> <abbr class="timeago" title="<?= $comment->date_created ?>"></abbr></i></small>
						<p><?= $comment->comment_container ?></p>	
				</div>
				<div class="editicon medium-1 large-1 column">
					<a class="editme"><i class="right fa fa-pencil-square-o"></i></a>
				</div>
			</div>
			<?php } ?>
		</div>
	</div>
</div>	
<?php } ?>

</div> <!-- end of postContainer -->				
			  </div>

	
		</div>
<!--Right div-->		
		<div class="profile-right-wall medium-5 large-5 column">

			<div class="right-bx-contain large-12 column">
				<div class="right-head large-12 column">
					<p>Groups</p>
				</div>
					<div class="right-content large-12 column">
						<div class="user-dp medium-2 large 2 column" style="background:url(img/user_dp/micro.jpg);background-size:cover;">
						</div>
						<div class="userinfo medium-7 large-8 column">
							<a href="">Microsoft Partner</a>
							<p><small>230 members</small></p>
						</div>
						<div class="text-right btn-lst medium-1 large-2 columns">
							<span class="right radius label">107</span>
						</div>
					</div>
					<div class="right-content large-12 column">
						<div class="user-dp medium-2 large 2 column" style="background:url(img/user_dp/symb.jpg);background-size:cover;">
						</div>
						<div class="userinfo medium-7 large-8 column">
							<a href="">Php User Group</a>
							<p><small>80 members</small></p>
						</div>
						<div class="text-right btn-lst medium-1 large-2 columns">
							<span class="right radius label">107</span>
						</div>
					</div>
				<div class="see-more text-right large-12 column">
					<a href="">See more group</a>
				</div>
			</div>

			<div class="right-bx-contain large-12 column" style="background:none;margin-top:-.5rem;">
				<?php $this->view->partial('common/footer'); ?>
			</div>
		</div>

<!--End Right div-->
	</div>
</div>


<script type="text/javascript">
	$(document).on('keypress','.commentbox',function(e) {
	  if(e.which == 13)
	  {	

	  	 var comment = $(this).val();
	  	 var feed_id = $(this).attr('id');
	  	 var receiver_id = $(this).attr('receiver-id'); //for notification
	  	 var sender_id = SS_USER_ID;
	  	 
	  	 if(!$.trim(comment) == '')
	  	 {
	  	 	$.ajax({
	  	 		url: URL + 'comments/insert',
	  	 		type: 'post',
	  	 		data:{comments:comment,feed_id:feed_id,receiver_id:receiver_id,sender_id:sender_id},
	  	 		dataType: 'json',
	  	 		success: function(result){
	  	 			if(result.status == true)
	  	 			{
	  	 				
	  	 			}
	  	 			else
	  	 			{
	  	 				//alert(result.messages);
	  	 			}
	  	 		}	
	  	 	})
	  	 }
	  	 $(this).val('');
	  	 $('.commentbox').blur();
	  }
	});

	function add_comment(data)
	{
		var template = $('#commentTpl').html();
		var html = Mustache.to_html(template,data);
		$('#feeds_comment_'+data.feeds_id).append(html).hide().fadeIn('slow');
	}

	$(document).ready(function(){
	$('#postLoading').hide();
	var pusher = new Pusher(PUSHER_APP_KEY);
	var channel = pusher.subscribe('my-channel');
	
	channel.bind('comment-added', function(data) {
	 	add_comment(data);
	 	jQuery("abbr.timeago").timeago();
	});
	channel.bind('likes-update', function(data) {
		var current = SS_USER_ID;
		$('#feeds_total_likes_'+data.feed_id).text(data.total_likes + ' People like this');
		if(current == data.user_id){
			if(data.type == 'like')
			{
				$('#feed_like_id_'+data.feed_id).text('Unlike');

			}
			else if(data.type ="unlike")
			{
				$('#feed_like_id_'+data.feed_id).text('Like');
			}
		}
		
	});

	});


jQuery(document).ready(function() {
	jQuery("abbr.timeago").timeago();
});

$(document).on("click",".btnLike",function(){
	var feed_id = $(this).attr('feed-like-id');
	var text = $(this).text();
	if(text == "Like")
	{
		$(this).text('Unlike');
		$.ajax({
			url: URL+'likes/insert',
			data: {feed_id:feed_id},
			type: 'post',
			dataType: 'json',
			success: function(result){
				if(result.status == true)
				{
					
				}
				else
				{
					
				}
			}
		})
	}
	else if(text == 'Unlike')
	{
		$(this).text('Like');
		$.ajax({
			url: URL+'likes/delete',
			data: {feed_id:feed_id},
			type: 'post',
			dataType: 'json',
			success: function(result){
				if(result.status == true)
				{
			
				}
				else
				{
					
				}
			}
		})	
	}
	
});

</script>